package file;

import java.io.*;

public class Crittografia {

	public static void main(String[] args) throws IOException {
		if (args.length == 0) {
			System.out.print("Attesa chiave");
			System.exit(-1);
		}
		int chiave = Integer.parseInt(args[0]);
		InputStream source = new FileInputStream("c:\\poo-file\\source.dat");
		OutputStream dest = new FileOutputStream("c:\\poo-file\\dest.dat");
		int dato;
		for (;;) {
			dato = source.read();
			if (dato == -1)
				break;
			dest.write(crittografa(dato, chiave));

		}
		source.close();
		dest.close();

	}

	static byte crittografa(int d, int chiave) {

		return (byte) (d + chiave);
	}

}
